﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Comm;

namespace CJGL
{
    public partial class ConfigForm : Form
    {
        public ConfigForm()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void ConfigForm_Load(object sender, EventArgs e)
        {
         

            this.txtscann_ip1.Text = XML.read("scanner_ip1", "p.xml");
            this.txtscann_prot1.Text = XML.read("scanner_port1", "p.xml");
         
            string ni = XML.read("alert_prot", "p.xml");
            cboAlert_prot.SelectedItem = ni;
            this.txtBaudrate.Text = XML.read("Baudrate", "p.xml");

            txtalertTime1.Text = XML.read("Alter_time1", "p.xml");
            txtalertTime3.Text = XML.read("Alter_time3", "p.xml");
            txtTCYS1.Text = XML.read("TCYS1", "p.xml");

        }

        private void button4_Click(object sender, EventArgs e)
        {
            XML.write("scanner_ip1", txtscann_ip1.Text, "p.xml");
            XML.write("scanner_port1", txtscann_prot1.Text, "p.xml");
            XML.write("Baudrate", txtBaudrate.Text, "p.xml");
            XML.write("alert_prot", cboAlert_prot.SelectedItem.ToString(), "p.xml");
            XML.write("Alter_time1", txtalertTime1.Text, "p.xml");
            XML.write("Alter_time3", txtalertTime3.Text, "p.xml");
            XML.write("TCYS1", txtTCYS1.Text, "p.xml");
            //赋值文件配置
            ClsParmart.scanner_ip1 = txtscann_ip1.Text;
            ClsParmart.scanner_port1 = txtscann_prot1.Text;
            ClsParmart.alert_prot = cboAlert_prot.SelectedItem.ToString();
            ClsParmart.Baudrate = txtBaudrate.Text;
            ClsParmart.TCYS1 = txtTCYS1.Text;
            //赋值文件配置
            ClsParmart.Alter_time1 = txtalertTime1.Text;
            ClsParmart.Alter_time3 = txtalertTime3.Text;
        

            MessageBox.Show("保存成功");
            this.Close();
        }

        private void txtscann_prot2_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
